home *** CD-ROM | disk | FTP | other *** search
/ Atari Forever 4 / Atari Forever 4 / Atari Forever 4.iso / SERIE_AI / AI_017 / INTERNET.TOS / SOFTWARE / TUWTCPSR / UDP.H < prev   
Encoding:
C/C++ Source or Header  |  1992-06-15  |  1.8 KB  |  56 lines

  1. #ifndef _INET_UDP
  2. #define _INET_UDP
  3.  
  4. #ifndef _INET_IP
  5. #include "ip.h"
  6. #endif
  7.  
  8. #ifndef _INET_ICUST
  9. #include "inetcust.h"
  10. #endif
  11.  
  12.  
  13.  
  14. typedef struct _udp
  15. {
  16.     unsigned src_port;            /* source port */
  17.     unsigned dst_port;            /* dest port */
  18.     unsigned length;            /* length of UDP packet incl. header */
  19.     unsigned chksum;            /* UDP checksum */
  20. } UDP;
  21.  
  22.  
  23. #ifndef __TCP_PSEUDO
  24. #define __TCP_PSEUDO
  25.  
  26. typedef struct                 /* tcp pseudoheader */
  27. {
  28.     INADDR    src;            /* source internet addr */
  29.     INADDR    dst;            /* destination internet addr */
  30.     u_short    protocol;        /* used protocol (hibyte must be zero!!) */
  31.     u_short    length;            /* length of tcp header + tcp data */
  32. } TCP_PSEUDO;
  33.  
  34. #endif
  35.  
  36. typedef int (*UDP_UPCALL)(int, char *, int);
  37.  
  38. /* The UDP Connection structure */
  39. typedef struct udp_ctl
  40. {
  41.     struct udp_ctl *next;        /* link to next udp port */
  42.     u_short        handle;            /* handle of this port */
  43.     u_short        lcl_port;        /* local port */
  44.     u_short        fgn_port;        /* foreign port */
  45.     INADDR        fhost;            /* foreign host */
  46.     UDP_UPCALL    upcall;            /* incoming packet handler */
  47.     u_short        udp_err;        /* send error */
  48.     u_short        data_len;        /* length of data */
  49.     char        *data;            /* data */
  50.     PACKET       *pkt;
  51.     TIMER        udp_tm;            /* timer how long to keep packet */
  52. } UDP_CTL;
  53.  
  54. #define UDP_KEEPPKT        400            /* 2 sec */
  55. #define UDP_MAXPORTS    4
  56.  
  57. #define UDP_OK        0        /* no error */
  58. #define UDP_OVR        1        /* overrun */
  59. #define UDP_MISS    2        /* packet timer expired */
  60. #define UDP_NORECV    3        /* destination unreachable */
  61. #define UDP_CLOSED    4        /* closed port */
  62.  
  63. #define udp_head(p_ip)    ((UDP *)(((char *)p_ip) + ip_hdrlen(p_ip)))
  64. #define udp_data(p_udp)    ((char *)(p_udp) + sizeof(UDP))
  65.  
  66. int udp_init(void);
  67. int udp_exit(void);
  68.  
  69. int udp_open(u_short,UDP_UPCALL);
  70. int udp_close(u_short);
  71. int udp_write(u_short,char *,u_short,INADDR, u_short);
  72. int udp_free(u_short);
  73. UDP_CTL *udp_getctl(u_short);
  74. #endif
  75.